/***********************************************************************
 * Module:  User.java
 * Author:  Voja
 * Purpose: Defines the Class User
 ***********************************************************************/

package model;

import java.util.*;

public class User {
   public int userId;
   public java.lang.String userEmailAddress;
   public java.lang.String userPassword;
   public java.lang.String userFirstName;
   public java.lang.String userLastName;
   public int userGender;
   public java.util.Date userDateOfBirth;
   public boolean userEmailNotifications;
   
   public java.util.Collection<User> followers;
   public java.util.Collection<Album> favorite;
   public java.util.Collection<Album> albums;
   public java.util.Collection<Rating> rating;
   public java.util.Collection<Comment> comments;
   public java.util.Collection<User> follows;
   public ProfileImage profileImage;
   
   
   /** @pdGenerated default getter */
   public java.util.Collection<User> getFollowers() {
      if (followers == null)
         followers = new java.util.HashSet<User>();
      return followers;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorFollowers() {
      if (followers == null)
         followers = new java.util.HashSet<User>();
      return followers.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newFollowers */
   public void setFollowers(java.util.Collection<User> newFollowers) {
      removeAllFollowers();
      for (java.util.Iterator iter = newFollowers.iterator(); iter.hasNext();)
         addFollowers((User)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newUser */
   public void addFollowers(User newUser) {
      if (newUser == null)
         return;
      if (this.followers == null)
         this.followers = new java.util.HashSet<User>();
      if (!this.followers.contains(newUser))
      {
         this.followers.add(newUser);
         newUser.addFollows(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldUser */
   public void removeFollowers(User oldUser) {
      if (oldUser == null)
         return;
      if (this.followers != null)
         if (this.followers.contains(oldUser))
         {
            this.followers.remove(oldUser);
            oldUser.removeFollows(this);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllFollowers() {
      if (followers != null)
      {
         User oldUser;
         for (java.util.Iterator iter = getIteratorFollowers(); iter.hasNext();)
         {
            oldUser = (User)iter.next();
            iter.remove();
            oldUser.removeFollows(this);
         }
      }
   }
   /** @pdGenerated default getter */
   public java.util.Collection<Album> getFavorite() {
      if (favorite == null)
         favorite = new java.util.HashSet<Album>();
      return favorite;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorFavorite() {
      if (favorite == null)
         favorite = new java.util.HashSet<Album>();
      return favorite.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newFavorite */
   public void setFavorite(java.util.Collection<Album> newFavorite) {
      removeAllFavorite();
      for (java.util.Iterator iter = newFavorite.iterator(); iter.hasNext();)
         addFavorite((Album)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newAlbum */
   public void addFavorite(Album newAlbum) {
      if (newAlbum == null)
         return;
      if (this.favorite == null)
         this.favorite = new java.util.HashSet<Album>();
      if (!this.favorite.contains(newAlbum))
      {
         this.favorite.add(newAlbum);
         newAlbum.addFavorites(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldAlbum */
   public void removeFavorite(Album oldAlbum) {
      if (oldAlbum == null)
         return;
      if (this.favorite != null)
         if (this.favorite.contains(oldAlbum))
         {
            this.favorite.remove(oldAlbum);
            oldAlbum.removeFavorites(this);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllFavorite() {
      if (favorite != null)
      {
         Album oldAlbum;
         for (java.util.Iterator iter = getIteratorFavorite(); iter.hasNext();)
         {
            oldAlbum = (Album)iter.next();
            iter.remove();
            oldAlbum.removeFavorites(this);
         }
      }
   }
   /** @pdGenerated default getter */
   public java.util.Collection<Album> getAlbums() {
      if (albums == null)
         albums = new java.util.HashSet<Album>();
      return albums;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorAlbums() {
      if (albums == null)
         albums = new java.util.HashSet<Album>();
      return albums.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newAlbums */
   public void setAlbums(java.util.Collection<Album> newAlbums) {
      removeAllAlbums();
      for (java.util.Iterator iter = newAlbums.iterator(); iter.hasNext();)
         addAlbums((Album)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newAlbum */
   public void addAlbums(Album newAlbum) {
      if (newAlbum == null)
         return;
      if (this.albums == null)
         this.albums = new java.util.HashSet<Album>();
      if (!this.albums.contains(newAlbum))
      {
         this.albums.add(newAlbum);
         newAlbum.setUser(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldAlbum */
   public void removeAlbums(Album oldAlbum) {
      if (oldAlbum == null)
         return;
      if (this.albums != null)
         if (this.albums.contains(oldAlbum))
         {
            this.albums.remove(oldAlbum);
            oldAlbum.setUser((User)null);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllAlbums() {
      if (albums != null)
      {
         Album oldAlbum;
         for (java.util.Iterator iter = getIteratorAlbums(); iter.hasNext();)
         {
            oldAlbum = (Album)iter.next();
            iter.remove();
            oldAlbum.setUser((User)null);
         }
      }
   }
   /** @pdGenerated default getter */
   public java.util.Collection<Rating> getRating() {
      if (rating == null)
         rating = new java.util.HashSet<Rating>();
      return rating;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorRating() {
      if (rating == null)
         rating = new java.util.HashSet<Rating>();
      return rating.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newRating */
   public void setRating(java.util.Collection<Rating> newRating) {
      removeAllRating();
      for (java.util.Iterator iter = newRating.iterator(); iter.hasNext();)
         addRating((Rating)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newRating */
   public void addRating(Rating newRating) {
      if (newRating == null)
         return;
      if (this.rating == null)
         this.rating = new java.util.HashSet<Rating>();
      if (!this.rating.contains(newRating))
      {
         this.rating.add(newRating);
         newRating.setUser(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldRating */
   public void removeRating(Rating oldRating) {
      if (oldRating == null)
         return;
      if (this.rating != null)
         if (this.rating.contains(oldRating))
         {
            this.rating.remove(oldRating);
            oldRating.setUser((User)null);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllRating() {
      if (rating != null)
      {
         Rating oldRating;
         for (java.util.Iterator iter = getIteratorRating(); iter.hasNext();)
         {
            oldRating = (Rating)iter.next();
            iter.remove();
            oldRating.setUser((User)null);
         }
      }
   }
   /** @pdGenerated default getter */
   public java.util.Collection<Comment> getComments() {
      if (comments == null)
         comments = new java.util.HashSet<Comment>();
      return comments;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorComments() {
      if (comments == null)
         comments = new java.util.HashSet<Comment>();
      return comments.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newComments */
   public void setComments(java.util.Collection<Comment> newComments) {
      removeAllComments();
      for (java.util.Iterator iter = newComments.iterator(); iter.hasNext();)
         addComments((Comment)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newComment */
   public void addComments(Comment newComment) {
      if (newComment == null)
         return;
      if (this.comments == null)
         this.comments = new java.util.HashSet<Comment>();
      if (!this.comments.contains(newComment))
      {
         this.comments.add(newComment);
         newComment.setUser(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldComment */
   public void removeComments(Comment oldComment) {
      if (oldComment == null)
         return;
      if (this.comments != null)
         if (this.comments.contains(oldComment))
         {
            this.comments.remove(oldComment);
            oldComment.setUser((User)null);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllComments() {
      if (comments != null)
      {
         Comment oldComment;
         for (java.util.Iterator iter = getIteratorComments(); iter.hasNext();)
         {
            oldComment = (Comment)iter.next();
            iter.remove();
            oldComment.setUser((User)null);
         }
      }
   }
   /** @pdGenerated default getter */
   public java.util.Collection<User> getFollows() {
      if (follows == null)
         follows = new java.util.HashSet<User>();
      return follows;
   }
   
   /** @pdGenerated default iterator getter */
   public java.util.Iterator getIteratorFollows() {
      if (follows == null)
         follows = new java.util.HashSet<User>();
      return follows.iterator();
   }
   
   /** @pdGenerated default setter
     * @param newFollows */
   public void setFollows(java.util.Collection<User> newFollows) {
      removeAllFollows();
      for (java.util.Iterator iter = newFollows.iterator(); iter.hasNext();)
         addFollows((User)iter.next());
   }
   
   /** @pdGenerated default add
     * @param newUser */
   public void addFollows(User newUser) {
      if (newUser == null)
         return;
      if (this.follows == null)
         this.follows = new java.util.HashSet<User>();
      if (!this.follows.contains(newUser))
      {
         this.follows.add(newUser);
         newUser.addFollowers(this);      
      }
   }
   
   /** @pdGenerated default remove
     * @param oldUser */
   public void removeFollows(User oldUser) {
      if (oldUser == null)
         return;
      if (this.follows != null)
         if (this.follows.contains(oldUser))
         {
            this.follows.remove(oldUser);
            oldUser.removeFollowers(this);
         }
   }
   
   /** @pdGenerated default removeAll */
   public void removeAllFollows() {
      if (follows != null)
      {
         User oldUser;
         for (java.util.Iterator iter = getIteratorFollows(); iter.hasNext();)
         {
            oldUser = (User)iter.next();
            iter.remove();
            oldUser.removeFollowers(this);
         }
      }
   }

}